# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import time
import datetime
from openerp.report import report_sxw

report_type = []

class partner_glassfix_report(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(partner_glassfix_report, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'get_account': self.get_account,
            
        })
        
    def get_account(self, uid, recordID, context={}):
        
        arrValues = [1, 2, 3 ,4 ,5] 
        dictValues = {'k1': 1, 'k2': 2, 'k3': 3,} 
        arrtValues2_dict =[{'k1': 1, 'k2': 2, 'k3': 3,}, {'k1': 4, 'k2': 5, 'k3': 6,}]  
        arrRes = []
            
        print 'partner_glassfix_report->get_account:'
        try:
            objBanks = self.pool.get('res.partner').browse(self.cr, uid, recordID, context=context).bank_ids
        
            nuCount = 0
            for item in objBanks:
#                 print str(item.state)
#                 print str(item.acc_number)
                nuCount += 1
                dictItem = {}
                dictItem["line_no"] = nuCount
                dictItem["state"] = item.state
                dictItem["acc_number"] = item.acc_number
                arrRes.append(dictItem)
            
            print '+ objBanks: ' + str(objBanks)
            print '+ arrRes: ' + str(arrRes)
        
        except:
            print '+ error.....'
            return False
        
        return arrRes
         
class sale_system_support_form(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(sale_system_support_form, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
        })        
        
        
        
        
        
        
report_sxw.report_sxw('report.partner_glassfix_reportname', 'res.partner', 'addons/crea8s_training2_report_glassfix/report/partner_glassfix_report.rml', parser=partner_glassfix_report, header=False)
report_sxw.report_sxw('report.sale_system_support_form_reportname', 'res.partner', 'addons/crea8s_training2_report_glassfix/report/sale_system_support_form.rml', parser=sale_system_support_form, header=False)


